<script lang="ts">
export default async function () {
	if (!window._reg) {
		window._reg = {
			serviceName: () => /^[^\d][a-z0-9-]{0,62}[a-z0-9]$/,
			email: () => /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
			mobile: () => /^1[34578]\d{9}$/,
			/**
			 * 以字母或者数字开头和结尾，由字母、数字连接符(-)、下划线(_)、点号(.)组成
			 */
			keyVal: () => /^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$/,
			keyValOnlyOne: () => /^[a-zA-Z0-9]$/,
			imageDesRe: "/^(?!\\s)[^<>]*$/",
			ipv4Reg: () =>
				/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?)$/i,
			ipv4CidrReg: () =>
				/^([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))(\.([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))){3}\/(([0-2]\d?)|(3[0-2]?)|([4-9]?))$/,
			ipv4WithZeroReg:
				/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)$/i,
			digitReg: "(0|[1-9][0-9]*)(-(0|[1-9][0-9]*))?",
			ipv4SegReg:
				/^(([1-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))(\.([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))){3})$/,
			port: () =>
				/^([1-9]|[1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/,
			rulePath: /^([\/][~';@\w-/.%?,#&=^$*+!:|\\\(\)\[\]\{\}]*)*$/,
			rulePathByRegex: /^[~';@\w-/.%?,#&=^$*+!:|\\\(\)\[\]\{\}]*$/,
			ruleHost: /^(?=^.{1,100}$)[a-zA-Z\d.\-?=~_+\\\^*!$&|\(\)\[\]]*$/,
			hostThenReg:
				/^(?=^.*$)[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?)+$/,
			hostReg:
				/^(?=^.*$)((\*)|([a-zA-Z0-9])(?:[-a-zA-Z0-9]*[a-zA-Z0-9])?)(?:\.[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?)+$/,
			printHeaderValueReg: /^[a-zA-Z0-9!#$%&'()*+,.\/:;<=>?@\[\]\\^_`{|}~-]*$/,
			printPartReg: /^[a-zA-Z0-9!$'\/()*+,.:;=?@^_`-]*$/,
			printMessageBodyReg: /^[a-zA-Z0-9\u4e00-\u9fa5!"#$%&'()*+,.\/:;<=>?@\[\]\\ ^_`{|}~-]*$/,
			printQueryPartReg: /^([a-zA-Z0-9!$'()*+,.\/:;=?@&^_`-]|(\${query}))*$/,
			headerKeyReg: /^[a-zA-Z0-9-_]*$/,
			urlPathReg: () => /^(\/([a-zA-Z0-9-._~!$&amp;\'()*+,;=:@%]|(%[a-fA-F0-9]{2}))*)+$/,
			/**
			 * 以/开头，由英文字母、数字或特殊字符-/.%?#&=组成
			 */
			url1: () => /^(\/([a-zA-Z0-9-\/.&amp;:?#=%]|(%[a-fA-F0-9]{2}))*)+$/,
			/**
			 * URL只能以/开头，由英文字母、数字或特殊字符_~`;@^-%#&$.*+?,=!:|V()[]{}组成
			 */
			url2: () =>
				/^(\/([a-zA-Z0-9-._~!$&amp;\')(}{*\[\]+,;=:@%#^?`\|]|(%[a-fA-F0-9]{2}))*)+$/,
			sharedUrlPathReg: /^(\/([a-zA-Z0-9-/.%?&amp_]|(%[a-fA-F0-9]{2}))*)+$/,
			guaranteedUrlPathReg:
				/^(\/([a-zA-Z0-9-._~!$&amp;\'()*\[\]+,;=:@%#^?]|(%[a-fA-F0-9]{2}))*)+$/,
			nameReg: "^[\\u4e00-\\u9fa5]$",
			priorityReg: /^((?!0)\d{1,2}|100)$/,
			idReg: /^[0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12}$/,
			integerReg: () => /^(0?|-?[1-9]\d*)$/,
			httpCodeReg: "^[2-5]\\d\\d(-[2-5]\\d\\d)?$",
			dscpReg: /^([1-9]|[1-5]\d{1}|6[0-3])$/,
			userDefinedHeaderValueReg: /^[\x21-\x7E]+$/,
			refrenceHeaderValueReg: /^[a-z0-9-_]*$/,
			cookieKeyReg: /^[a-zA-Z0-9\!\"\%\'\(\)\*\+\,\-\.\/\:\=\?\@\^\_\`\~]*$/,
			nameRe: "/^[a-zA-Z0-9_]*$/",
			ChineseRe: "[\\u4e00-\\u9fa5a-zA-Z0-9-_.]*",
			NatNameRe: "[\\u4e00-\\u9fa5a-zA-Z0-9-_]*",
			ChineseNotHyphensRe: "[\\u4e00-\\u9fa5a-zA-Z0-9-_]*",
			extendName: "/^(?!\\s)(?!.*?\\s$)[a-zA-Z0-9_.\\-\\s]*$/",
			desRe: "^[^<>]*$",
			imageName: "/^(?!\\s)(?!.*?\\s$)[a-zA-Z0-9_.\\-\\s]{1,128}$/",
			notEmpty: "/^[\\S]*$/",
			VolumenameRe: "^[a-zA-Z0-9_]*$",
			unixFilePathName: "/^(/\\w+)+(\\.\\w+)?$/",
			winFilePathName: "/^[a-zA-Z]:(\\\\\\w+)+(\\.\\w+)?$/",
			letterNumber: "/^[a-zA-Z0-9]+$/",
			// phoneRe: () => /((d{11})|^((d{7,8})|(d{4}|d{3})-(d{7,8})|(d{4}|d{3})-(d{7,8})-(d{4}|d{3}|d{2}|d{1})|(d{7,8})-(d{4}|d{3}|d{2}|d{1}))$)/,
			phoneRe: () => /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
			macRe: "^[A-Fa-f\\d]{2}:[A-Fa-f\\d]{2}:[A-Fa-f\\d]{2}:[A-Fa-f\\d]{2}:[A-Fa-f\\d]{2}:[A-Fa-f\\d]{2}$",
			notAllSpaceReg: "/^.*[^ ].*$/",
			/**
			 * 只返回数字
			 * @return {RegExp}
			 */
			notAllNumReg: () => /^[0-9]*$/,
			spaceReg: /\s+/,
			domainIDReg: /^[a-zA-Z0-9-]{1,64}$/,
			hostRegWaf:
				/^(?=^.{3,255}$)[*a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+$|^\*$/,
			domainName:
				"(^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(.[-a-zA-Z0-9]{1,63})*(.[-a-zA-Z0-9]{0,62}[a-zA-Z0-9])$)|(^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$)|(^[a-zA-Z0-9]$)",
			domainReg: () =>
				/^(?=^.{3,100}$)[a-zA-Z0-9](?:[-a-zA-Z0-9]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-a-zA-Z0-9]{0,61}[a-zA-Z0-9])?)+$/,
			domainRegWildCard:
				/^(?=^.{1,100}$)[a-zA-Z\d\*\?\-=~_+\\\^!$&|\(\)\[\]]((?!.*\.\.)[a-zA-Z\d\*\?\-\.=~_+\\\^!$&|\(\)\[\]]*[a-zA-Z\d\*\?\-=~_+\\\^!$&|\(\)\[\]])?$/,
			domainNew:
				/^(?=^.{3,100}$)((\*)|((\*)[a-zA-Z0-9])|([a-zA-Z0-9]))(?:[-a-zA-Z0-9]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-a-zA-Z0-9]{0,61}[a-zA-Z0-9])?)+$/,
			dnsSearchDomainNew:
				/^(?=^.{3,254}$)((\*)|((\*)[a-zA-Z0-9])|([a-zA-Z0-9]))(?:[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([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,
			projectId: /^[0-9a-z]{32}$/,
			cifsDirReg:
				/^((\\\\(([1-9]|[1-9]\d|(10|11)\d|12[0-6]|12[8-9]|1[3-9]\d|2[0-1]\d|22[0-3])(\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3})){1})((((\\){1})([a-zA-Z0-9-_ .]{1,})){1,})$/,
			nfsDirReg:
				/^([1-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}:\/[\S.]+$/,
			DeviceName: "(^/dev/xvd)[e-z]{1}$",
			DeviceNameRe: "/(^/dev/xvd)[e-z]{1}$/",
			tenantIdReg: /^[0-9a-z]{32}$/,
			uuidReg: /^[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12}$/,
			containUuidReg: /[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12}/g,
			maskReg: "^([0-9]|[1-2][0-9]|3[0-2])$",
			maskIpv6Reg: "^([0-9]|[1-9][0-9]|1[0-2][0-8])$",
			tenantNameValid: "/^[A-Za-z-\\s][A-Za-z0-9_-\\s]*$/",
			pskofVPNReg: /^[^<>&?*'"\s]+$/,
			projectNameValid: "/^[A-Za-z_-][A-Za-z0-9_-\\s]*$/",
			cidrRangeReg:
				/^([1-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\/([1-9]|[1-2]\d|3[0-2])\~([1-9]|[1-2]\d|3[0-2])$/,
			DCRe: "[a-zA-Z0-9-_]*",
			certContent:
				"[-]{5}BEGIN[^<>-]+[-]{5}(\r)?\n([^-<> \f\n\r\t\v]+(\r)?\n{1})+[-]{5}END[^<>-]+[-]{5}",
			privateKeyContent:
				"([-]{5}BEGIN[^<>-]+[-]{5}(\r)?\n([^-<> \f\n\r\t\v]+(\r)?\n{1})+[-]{5}END[^<>-]+[-]{5}(\r)?\n)?[-]{5}BEGIN[^<>-]+[-]{5}(\r)?\n([^-<> \f\n\r\t\v]+(\r)?\n{1})+[-]{5}END[^<>-]+[-]{5}",
			/**
			 * 工作负载名称校验
			 * workloadName: /^[a-z]([-a-z0-9]*[a-z0-9])?$/
			 * @returns {RegExp}
			 */
			workloadName: () => /^[a-z]([-a-z0-9]*[a-z0-9])?$/,
			/**
			 * 端口名称校验
			 */
			scRancherPortName: () => /^(?=.*\d)(?=.*[a-zA-Z])/,
			/**
			 * 环境变量名称校验
			 */
			scEnvName: () => /[-._a-zA-Z][-._a-zA-Z0-9]*'/
		};
	}

	return window._reg;
}
</script>
